﻿ 

 

// ******************************************************
// 这段代码是自动生成的
// 修改里面的代码，下次生成的时候会被覆盖
// ******************************************************
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.ServiceModel;
using System.Threading.Tasks;
using Sharp.Application;
using Sharp.DataTransferObject;
using Sharp.ServiceContracts;
using Sharp.Infrastructure;
using System.ServiceModel.Activation;
using Sharp.Infrastructure.Search;
using Sharp.Infrastructure.IoC;
using Sharp.Infrastructure.Interfaces;
namespace Sharp.Services
{
	//[DebuggerStepThrough]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
	[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
	public class UserService : IUserService
	{
		private readonly IUserService _userServiceImpl = ServiceLocator.Instance.GetService<IUserService>();
		public Result ResetPassword(ResetPasswordDTO userdto)
		{
			try
			{
				return _userServiceImpl.ResetPassword(userdto);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SaveUser(UserDTO user)
		{
			try
			{
				return _userServiceImpl.SaveUser(user);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteUsers(IList<System.Int32> userids)
		{
			try
			{
				return _userServiceImpl.DeleteUsers(userids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean ValidateUser(String userName, String password)
		{
			try
			{
				return _userServiceImpl.ValidateUser(userName, password);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean DisableUser(UserDTO user)
		{
			try
			{
				return _userServiceImpl.DisableUser(user);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean UnlockUser(String userName)
		{
			try
			{
				return _userServiceImpl.UnlockUser(userName);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean EnableUser(UserDTO user)
		{
			try
			{
				return _userServiceImpl.EnableUser(user);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<Sharp.DataTransferObject.UserDTO> GetUserByKey(Int32 id)
		{
			try
			{
				return _userServiceImpl.GetUserByKey(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<Sharp.DataTransferObject.UserDTO> GetUserByEmail(String email)
		{
			try
			{
				return _userServiceImpl.GetUserByEmail(email);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<Sharp.DataTransferObject.UserDTO> GetUserByName(String userName)
		{
			try
			{
				return _userServiceImpl.GetUserByName(userName);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.UserDTO> GetUsersPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetUsersPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.UserDTO> GetUsersPagedForGroup(PagingFeature pf, Int32 groupId, Boolean includeGroup)
		{
			try
			{
				return _userServiceImpl.GetUsersPagedForGroup(pf, groupId, includeGroup);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.UserDTO> GetUsersPagedForRole(PagingFeature pf, Int32 roleId, Boolean includeRole)
		{
			try
			{
				return _userServiceImpl.GetUsersPagedForRole(pf, roleId, includeRole);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result AssignRole(Int32[] userIds, Int32 roleId)
		{
			try
			{
				return _userServiceImpl.AssignRole(userIds, roleId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result UnassignRole(Int32[] userIds, System.Nullable<System.Int32> roleId)
		{
			try
			{
				return _userServiceImpl.UnassignRole(userIds, roleId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IEnumerable<Sharp.DataTransferObject.PermissionDTO> GetPermissionByUserName(String username)
		{
			try
			{
				return _userServiceImpl.GetPermissionByUserName(username);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean ChangePassword(String username, String oldPassword, String newPassword)
		{
			try
			{
				return _userServiceImpl.ChangePassword(username, oldPassword, newPassword);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Boolean ChangePasswordQuestionAndAnswer(String username, String password, String newPasswordQuestion, String newPasswordAnswer)
		{
			try
			{
				return _userServiceImpl.ChangePasswordQuestionAndAnswer(username, password, newPasswordQuestion, newPasswordAnswer);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<Sharp.DataTransferObject.UserDTO> TryLogin(UserDTO userDTO)
		{
			try
			{
				return _userServiceImpl.TryLogin(userDTO);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void SaveLog(String log)
		{
			try
			{
				 _userServiceImpl.SaveLog(log);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public UserLogDTO GetUserLogInfo(Int32 id)
		{
			try
			{
				return _userServiceImpl.GetUserLogInfo(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteUserLogs(Int32[] ids)
		{
			try
			{
				return _userServiceImpl.DeleteUserLogs(ids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.UserLogDTO> GetUserLogPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetUserLogPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result RelationUser(int[] roleIds, int[] userIds)
		{
			try
			{
				return _userServiceImpl.RelationUser(roleIds, userIds);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}

	    public Result RelationUserForGroup(Int32 groupId, Int32[] userIds)
		{
			try
			{
				return _userServiceImpl.RelationUserForGroup(groupId, userIds);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result UnRelationUserForGroup(Int32 groupId, Int32[] userIds)
		{
			try
			{
				return _userServiceImpl.UnRelationUserForGroup(groupId, userIds);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result ForgotPassword(ForgotPasswordDTO dto)
		{
			try
			{
				return _userServiceImpl.ForgotPassword(dto);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result<System.Int32> IncrementAccessFailedCount(Int32 userId)
		{
			try
			{
				return _userServiceImpl.IncrementAccessFailedCount(userId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void ResetAccessFailedCount(Int32 userId)
		{
			try
			{
				 _userServiceImpl.ResetAccessFailedCount(userId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void SetLockoutEnabled(Int32 id, Boolean enabled)
		{
			try
			{
				 _userServiceImpl.SetLockoutEnabled(id, enabled);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void SetLockoutEndDate(Int32 id, DateTimeOffset lockoutEnd)
		{
			try
			{
				 _userServiceImpl.SetLockoutEndDate(id, lockoutEnd);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SendMessage(MessageDTO model)
		{
			try
			{
				return _userServiceImpl.SendMessage(model);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DraftMessage(MessageDTO model)
		{
			try
			{
				return _userServiceImpl.DraftMessage(model);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteMessages(Int32[] ids)
		{
			try
			{
				return _userServiceImpl.DeleteMessages(ids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public MessageDTO GetMessageInfo(Int32 id)
		{
			try
			{
				return _userServiceImpl.GetMessageInfo(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.MessageDTO> GetMessagePaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetMessagePaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.MessageDTO> GetMessageOutboxPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetMessageOutboxPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.MessageDTO> GetMessageDraftboxPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetMessageDraftboxPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.MessageDTO> GetMessageDustbinPaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetMessageDustbinPaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Task<Result<IList<Sharp.DataTransferObject.MessageDTO>>> NoReadMessages()
		{
			try
			{
				return _userServiceImpl.NoReadMessages();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SendNotice(NoticeDTO model)
		{
			try
			{
				return _userServiceImpl.SendNotice(model);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteNotices(Int32[] ids)
		{
			try
			{
				return _userServiceImpl.DeleteNotices(ids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public NoticeDTO GetNoticeInfo(Int32 id)
		{
			try
			{
				return _userServiceImpl.GetNoticeInfo(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Task<Result<IList<Sharp.DataTransferObject.NoticeDTO>>> NoReadNotices()
		{
			try
			{
				return _userServiceImpl.NoReadNotices();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.NoticeDTO> GetNoticePaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetNoticePaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Task<IEnumerable<Sharp.DataTransferObject.PermissionDTO>> AllPermissions()
		{
			try
			{
				return _userServiceImpl.AllPermissions();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Task<IEnumerable<Sharp.DataTransferObject.PermissionDTO>> AllAvailablePermissions()
		{
			try
			{
				return _userServiceImpl.AllAvailablePermissions();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Task<IEnumerable<Sharp.DataTransferObject.PermissionDTO>> GetPermissionByRoleId(Int32 roleId)
		{
			try
			{
				return _userServiceImpl.GetPermissionByRoleId(roleId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SavePermission(IList<System.Guid> ids, String owner, Int32 ownerId)
		{
			try
			{
				return _userServiceImpl.SavePermission(ids, owner, ownerId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Task<IEnumerable<Sharp.DataTransferObject.PermissionDTO>> GetPermissionById(Int32 userId)
		{
			try
			{
				return _userServiceImpl.GetPermissionById(userId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result RefurbishAvailablePermissionData(IList<Sharp.DataTransferObject.PermissionDTO> dtos, String columns)
		{
			try
			{
				return _userServiceImpl.RefurbishAvailablePermissionData(dtos, columns);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result AllotAllPermissionToAdminRole()
		{
			try
			{
				return _userServiceImpl.AllotAllPermissionToAdminRole();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result AvailablePermissionToPermission(Guid[] ids)
		{
			try
			{
				return _userServiceImpl.AvailablePermissionToPermission(ids);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SaveOrgPermission(Guid[] orgIds, Int32 roleId)
		{
			try
			{
				return _userServiceImpl.SaveOrgPermission(orgIds, roleId);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result SaveRole(RoleDTO roleDTO)
		{
			try
			{
				return _userServiceImpl.SaveRole(roleDTO);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IList<Sharp.DataTransferObject.RoleDTO> GetRoles()
		{
			try
			{
				return _userServiceImpl.GetRoles();
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public RoleDTO GetRoleByKey(Int32 id)
		{
			try
			{
				return _userServiceImpl.GetRoleByKey(id);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public Result DeleteRoles(IList<System.Int32> roleIDs)
		{
			try
			{
				return _userServiceImpl.DeleteRoles(roleIDs);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public PagedResult<Sharp.DataTransferObject.RoleDTO> GetRolePaged(PagingFeature pf)
		{
			try
			{
				return _userServiceImpl.GetRolePaged(pf);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
	}
}


